﻿using System;
using System.Linq.Expressions;
using Coder.Object2Report;
using Fee.VendorMatchers;
using Text.Helper;

namespace Fee.IO.Exporters
{
    public class VendorMatcherExportor : BaseExportor<VendorMatcher>
    {

        protected override string SheetName => "供应商映射";

        protected override Report<VendorMatcher> CreateReportStructure(RenderBase render)
        {
            var result = new Report<VendorMatcher>(render);
            result.Column("年份", f => f.Year);
            result.Column("区域", f => f.District != null ? f.District.Name : "");
            result.Column("类型", f => f.ContractType.GetEnumDisplayName());

            result.Column("建设类型", f => f.ConstructionType.GetEnumDisplayName());

            Func<VendorMatcher, string> expression = (f) =>
            {
                if (f is ConstructionVendorMatcher imple)
                    return imple.StationType.GetEnumDisplayName();
                return "";
            };
            result.Column("站点类型", expression);

            result.Column("供应商", f => f.Vendor != null ? f.Vendor.Name : "");
            result.Column("执行类型", f => f.ContractType.GetEnumDisplayName());

            return result;
        }
    }
}